﻿using System;
using GameFramework.skill.effect;
using GameFramework.skill.selector;

namespace GameFramework.skill.deployer
{
    public class DeployerConfigFactory//反射来实现
    {
        //选择器的命名空间
        public static string selectorNameSpace = "GameFramework.skill.selector.impl";
        public static string effectNameSpace = "GameFramework.skill.effect.impl";
        //选择器类名后缀
        public static string selectorSuffix = "SkillSelector";
        public static string effectSuffix = "SkillEffect";
        public static ISkillSelector CreateSkillSelector(Skill data)//范围选择算法 
        {
            // string className = string.Format("MOBASkill.{0}SkillSelector", data.skillConfig.selectorType);
            // string className = string.Format(selectorNameSpace+".{0}"+selectorSuffix, data.skillConfig.selectorType);
            return CreateObject<ISkillSelector>("");
        }
        
        public static ISkillEffect[] CreateImpactEffects(Skill data) //效果算法
        {
            //计算效果数量 data.skillConfig
            // int tempEffectNum = data.skillConfig.effectType.Length;
            ISkillEffect[] impacts = new ISkillEffect[1];
            // for (int i = 0; i < tempEffectNum; i++)
            // {
            //     //TODO 根据效果名组装类名
            //     // string classname = string.Format("MOBASkill.{0}Impact", data.impactType[i]);
            //     string classname = string.Format(effectNameSpace+".{0}"+effectSuffix, data.skillConfig.effectType[i]);
            //     impacts[i] = CreateObject<ISkillEffect>(classname);
            // }
            return impacts;
        }
        private static T CreateObject<T>(string className) where T : class//创建对应算法
        {
            Type type = Type.GetType(className);
            return Activator.CreateInstance(type) as T;
        }
    }
}